package com.zxy.actspringboot.controller;

import com.zxy.actspringboot.service.ActivitiWorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : zhangxuyuan
 * @Project: activitiSpringbootTest
 * @Package com.zxy.actspringboot.controller
 * @date Date : 2021年02月02日 10:21
 */

@RestController
public class IndexController {

    @Autowired
    private ActivitiWorkflowService workflowService;

    /**
     * 提交一个流程，例如请假流程
     * @param key
     * @param assign
     * @return
     */
    @GetMapping("/startProcess/{key}/{assign}")
    public String startProcess(@PathVariable("key")String key,
                                @PathVariable("assign")String assign)
    {
        String s = workflowService.startProcess(key, assign);
        return s;
    }

    /**
     * 用户执行任务
     * @param id
     * @param assign
     * @param params
     * @return
     */

    @GetMapping("/complete/{instanceId}/{assign}")
    public String completeTask(@PathVariable("instanceId")String id,
            @PathVariable("assign")String assign,@RequestBody Map<String,Object> params)
    {
        String s = workflowService.completeTask(id, assign, params);
        return s;
    }
}
